package com.competition.reception.controller;


import com.competition.commonutils.R;
import com.competition.reception.entity.User;
import com.competition.reception.entity.vo.UserQueryVo;
import com.competition.reception.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-04-03
 */
@RestController
@RequestMapping("/reception/user")
@Api(description = "后台用户相关的接口")
@CrossOrigin
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation("根据条件查询用户")
    @PostMapping("selectUserByCondition")
    public R selectUserByCondition(@RequestBody UserQueryVo userQueryVo){
        return userService.getUserByCondition(userQueryVo);
    }
    @ApiOperation("根据id添加/移除用户到黑名单")
    @PostMapping("BlacklistUser/{id}")
    public R userBlackListManage(@PathVariable("id") String id){
        Integer is_black=userService.userBlackListManage(id);
        return R.ok().data("is_black",is_black);
    }
    @ApiOperation("删除用户,根据用户id")
    @DeleteMapping("deleteUser/{id}")
    public R deleteUser(@PathVariable("id") String id){
        boolean delete = userService.removeById(id);
        return delete==true?R.ok():R.error();
    }
}

